<?php
// open the text file
$file = "limetorrrents.csv";
$fd = fopen ("$file", "r");
$con = mysql_connect("sql212.xtreemhost.com","xth_8628058","thinkcom");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("xth_8628058_ikbhal", $con);
// initialize a loop to go through each line of the file
while (!feof ($fd)) {
	$buffer = fgetcsv($fd, 4096); // declare an array to hold all of the contents of each
	//row, indexed
	echo "n";
	// this for loop to traverse thru the data cols
	// when this is re-created with MySQL use the mysql_num_fileds() function to get
	// this number
	//	seeds	leaches	title	url	addedDate	turl	size

	$title = $buffer[2];
	$seeds = $buffer[0];
	$leaches = $buffer[1];
	$size = $buffer[6];	
	$addedDate = $buffer[4];
	$url = $buffer[6];
	$sql ="INSERT INTO torrent (title, seeds, leaches,size,url,addedDate)
VALUES ('"+$title+"', "+$seeds+", "+$leaches+",'"+$size+"','"+$url+"','"+$addedDate+"')";
	mysql_query($sql);

	echo "$sql<hr/>";
}
mysql_close($con);
fclose ($fd);
?>